home *** CD-ROM | disk | FTP | other *** search
/ TPUG - Toronto PET Users Group / TPUG Users Group CD / TPUG Users Group CD.iso / AMIGA / AMICUS / AMICUS20.ADF / BobEd / main.c < prev    next >
C/C++ Source or Header  |  1989-01-27  |  4KB  |  138 lines

  1. /**********************************************************************
  2.  *
  3.  *    BobEd V1.5
  4.  *    (C) 1986, Peter Philip.
  5.  *    This program is free to distribute as long as the following
  6.  *    conditions are met : 1) You do not make a profit from it.
  7.  *                         2) This notice is not removed.
  8.  *    Simple eh? :-)
  9.  *
  10.  *    BobEd V1.0 consists of the following source files :
  11.  *       main.c, events.c, drawbox.c, gadgets.c,
  12.  *       menus.c, disk.c, requesters.c, bobed.h
  13.  *
  14.  *    The file BobEd.doc contains the instructions for this program.
  15.  *
  16.  *    If you find this program really useful a small contribution
  17.  *    of no more than $10 would be nice, OR if you send postage I will
  18.  *    let you know when I have a greatly improved version completed.
  19.  *
  20.  *       Peter Philip
  21.  *       111 Ancaster Ct.
  22.  *       Dartmouth, N.S.
  23.  *       B2V 1J2, CANADA
  24.  *
  25.  ******************************************************************** */
  26.  
  27. #include <bobed.h>
  28.  
  29. long GfxBase,IntuitionBase;
  30.  
  31. extern doevent ();
  32. extern drawboxes ();
  33. extern makemenu ();
  34. extern makegads ();
  35.  
  36. struct Window   *w;
  37. struct Screen   *screen;
  38. struct RastPort *rp;
  39. struct ViewPort *vp;
  40.  
  41. /* gadget structure definitions  */
  42. extern struct Gadget colgad [COLORS];
  43.  
  44. /* menu structure definitions    */
  45. extern struct Menu menu [MENUS];
  46.  
  47. /* image data */
  48. UBYTE bobdata [OBS+1][BWIDE*16][BHIGH]; /* one extra for buffer   */
  49.  
  50. struct TextAttr TestFont = { "topaz.font", 8, 0, 0 };
  51.  
  52. struct NewScreen ns = {
  53. 0, 0,                    /* left edge, top edge */
  54. WIDE,HIGH,DEPTH,         /* width, height    */
  55. 2, 1,                    /* detail pen, block pen */
  56. MODE,                    /* viewing mode     */
  57. CUSTOMSCREEN,            /* screen type */
  58. &TestFont,               /* font to use */
  59. "BobEd V1.5",            /* default title for screen */
  60. NULL                     /* pointer to additional gadgets */
  61. };
  62.  
  63. struct NewWindow nw = {
  64. 00, 00,                  /* left edge, top edge */
  65. WIDE, HIGH,              /* width, height */
  66. 2, 1,                    /* detail pen, block pen*/
  67. MOUSEBUTTONS|MOUSEMOVE|
  68. GADGETUP|MENUPICK,       /* IDCMP flags */
  69. SMART_REFRESH|REPORTMOUSE|
  70. ACTIVATE|NOCAREREFRESH,  /* window flags */
  71. (struct Gadget *)&colgad[0], /* user gadgets */
  72. NULL,                    /* pointer to user checkmark    */
  73. "BobEd 1.5",             /* window title */
  74. NULL,                    /* pointer to screen(later)*/
  75. NULL,                    /* pointer to superbitmap */
  76. 0,0,                     /* minimum size (not used)   */
  77. WIDE,HIGH,               /* max size of window (not used) */
  78. CUSTOMSCREEN             /* type of screen in which to open */
  79. };
  80.  
  81. /* -------------------------------------------------------------------- */
  82.  
  83. main()
  84. {
  85.    GfxBase = OpenLibrary("graphics.library",LIBRARY_VERSION);
  86.    if (GfxBase == NULL)
  87.    {
  88.       exit(1000);
  89.    }
  90.  
  91.    IntuitionBase = OpenLibrary("intuition.library",LIBRARY_VERSION);
  92.    if (IntuitionBase == NULL)
  93.    {
  94.       CloseLibrary (GfxBase);
  95.       exit(1000);
  96.    }
  97.  
  98.    screen = (struct Screen *)OpenScreen(&ns);  /* open our custom screen */
  99.    if (screen == NULL)
  100.    {
  101.       CloseLibrary (GfxBase);
  102.       CloseLibrary (IntuitionBase);
  103.       exit (1000);
  104.    }
  105.    nw.Screen = screen;        /* link to the window   */
  106.  
  107.    makegads ();   /* initialise the gadgets */
  108.  
  109.    w = (struct Window *)OpenWindow(&nw);       /* open our window */
  110.    if (w == NULL)
  111.    {
  112.       CloseLibrary (GfxBase);
  113.       CloseLibrary (IntuitionBase);
  114.       CloseScreen (screen);
  115.       exit (1000);
  116.    }
  117.  
  118.    makemenu ();   /* initialise the menus */
  119.    SetMenuStrip (w,&menu[0]);
  120.  
  121.    initdiskreq ();   /* initialise the requesters  */
  122.  
  123.    rp = w->RPort;             /* get address of rastport */
  124.    vp = &w->WScreen->ViewPort;          /* and viewport  */
  125.  
  126.    drawboxes ();     /* draw the image boxes */
  127.    doevent ();       /* process events forever */
  128. }
  129.  
  130. VOID  bye ()       /* exits program closing all resources allocated */
  131. {
  132.    CloseWindow (w);
  133.    CloseScreen (screen);
  134.    CloseLibrary (IntuitionBase);
  135.    CloseLibrary (GfxBase);
  136.    exit (TRUE);
  137. }
  138.